﻿@page "/scheduler/local-data"

@using Syncfusion.Blazor.Schedule
@inherits SampleBaseComponent;

<SampleDescription>
    <p>  This demo shows the way of binding appointments with local datasource.</p>
</SampleDescription>
<ActionDescription>
    <p>Scheduler can be bound either to local or remote data services which will load the data by default on demand to reduce the data transfer and load time. In this sample, the <code>DataSource</code> property available within the <code>EventSettings</code> needs to be assigned with the valid local list data. </p>
</ActionDescription>

<div class="col-lg-12 control-section">
    <div class="schedule-wrapper">
        <SfSchedule TValue="AppointmentData" Width="100%" Height="650px" @bind-SelectedDate="@CurrentDate">
            <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
            <ScheduleViews>
                <ScheduleView Option="View.Day"></ScheduleView>
                <ScheduleView Option="View.Week"></ScheduleView>
                <ScheduleView Option="View.WorkWeek"></ScheduleView>
                <ScheduleView Option="View.Month"></ScheduleView>
                <ScheduleView Option="View.Agenda"></ScheduleView>
            </ScheduleViews>
        </SfSchedule>
    </div>
</div>

@code{
    private DateTime CurrentDate = new DateTime(2020, 1, 9);
    public List<AppointmentData> DataSource = GetScheduleData();
    public class AppointmentData
    {
        public int Id { get; set; }
        public string Subject { get; set; }
        public string Location { get; set; }
        public string Description { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public Nullable<bool> IsAllDay { get; set; }
        public string CategoryColor { get; set; }
        public string RecurrenceRule { get; set; }
        public Nullable<int> RecurrenceID { get; set; }
        public string RecurrenceException { get; set; }
        public string StartTimezone { get; set; }
        public string EndTimezone { get; set; }
    }
    static public List<AppointmentData> GetScheduleData()
    {
        List<AppointmentData> appData = new List<AppointmentData>();
        appData.Add(new AppointmentData
        {
            Id = 1,
            Subject = "Explosion of Betelgeuse Star",
            Location = "Space Centre USA",
            StartTime = new DateTime(2020, 1, 5, 9, 30, 0),
            EndTime = new DateTime(2020, 1, 5, 11, 0, 0),
            CategoryColor = "#1aaa55"
        });
        appData.Add(new AppointmentData
        {
            Id = 2,
            Subject = "Thule Air Crash Report",
            Location = "Newyork City",
            StartTime = new DateTime(2020, 1, 6, 12, 0, 0),
            EndTime = new DateTime(2020, 1, 6, 14, 0, 0),
            CategoryColor = "#357cd2"
        });
        appData.Add(new AppointmentData
        {
            Id = 3,
            Subject = "Blue Moon Eclipse",
            Location = "Space Centre USA",
            StartTime = new DateTime(2020, 1, 7, 9, 30, 0),
            EndTime = new DateTime(2020, 1, 7, 11, 0, 0),
            CategoryColor = "#7fa900"
        });
        appData.Add(new AppointmentData
        {
            Id = 4,
            Subject = "Meteor Showers in 2018",
            Location = "Space Centre USA",
            StartTime = new DateTime(2020, 1, 8, 13, 0, 0),
            EndTime = new DateTime(2020, 1, 8, 14, 30, 0),
            CategoryColor = "#ea7a57"
        });
        appData.Add(new AppointmentData
        {
            Id = 5,
            Subject = "Milky Way as Melting pot",
            Location = "Space Centre USA",
            StartTime = new DateTime(2020, 1, 9, 12, 0, 0),
            EndTime = new DateTime(2020, 1, 9, 14, 0, 0),
            CategoryColor = "#00bdae"
        });
        return appData;
    }
}